/**
 * FileName: MyAdviceAdvice
 * Author:   powersi
 * Date:     2021/3/18 8:52
 * Description:
 */
package com.zm.demo.spring.aop.api;

import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.ThrowsAdvice;

import java.lang.reflect.Method;

/**
 * Description: 
 * Author:      powersi
 * Date:        2021/3/18 8:52
 */
//public class MyAdviceAdvice implements MethodBeforeAdvice, ThrowsAdvice {
public class MyAdviceAdvice implements MethodBeforeAdvice, AfterReturningAdvice, ThrowsAdvice {


    @Override
    public void afterReturning(Object o, Method method, Object[] objects, Object o1) throws Throwable {
        System.out.println("===== afterReturning " + method.getName());
    }

    @Override
    public void before(Method method, Object[] objects, Object o) throws Throwable {
        System.out.println("===== before " + method.getName());
    }

    public void afterThrowing(Method m, Object args, Object target,
                              Throwable subclass) {
        System.out.println("[DaoThrowsAdvice]: An exception occur: "
                + subclass.getClass().getSimpleName());
        System.exit(0);
    }
}
